import { Component } from "../../core/Component";
import { ecs_component } from "../../core/Component";
import { Entity } from "../../core/Entity";

@ecs_component("ECPosition")
export class ECPosition extends Component {
    public x: number = 0;
    public y: number = 0;
    public z: number = 0;

    onRecycle() {
        this.x = 0;
        this.y = 0;
        this.z = 0;
    }

    onReuse() {
        this.x = 0;
        this.y = 0;
        this.z = 0;
    }
}

export class ECPositionHelper {
    static setPosition(entity: Entity, x:number, y:number, z:number = 0):ECPosition {
        let ecPosition = entity.getOrAddComponent(ECPosition);
        ecPosition.x = x;
        ecPosition.y = y;
        ecPosition.z = z;
        return ecPosition;
    }
}
